<?php
    $dom = new DOMDocument();

    $dom->load($csv);

    $rows =  $dom->getElementsByTagName("Row");

    $count = 0;

?>

<h2 class="h2-title">Import Product !!!</h2>

<form action="<?=base_url()?>backend/product/import_from_csv" method="POST">
<table style="width: 100%;">

<?php foreach($rows as $row):?>
    <?php if($count == 0):?>
        <th><?=$row->getElementsByTagName("Cell")->item(0)->nodeValue?></th>
        <th><?=$row->getElementsByTagName("Cell")->item(1)->nodeValue?></th>
        <th><?=$row->getElementsByTagName("Cell")->item(2)->nodeValue?></th>
        <th><?=$row->getElementsByTagName("Cell")->item(3)->nodeValue?></th>
        <th><?=$row->getElementsByTagName("Cell")->item(4)->nodeValue?></th>
        <th><?=$row->getElementsByTagName("Cell")->item(5)->nodeValue?></th>
        <th><?=$row->getElementsByTagName("Cell")->item(6)->nodeValue?></th>
    <?php else:?>
        <tr>
            <td><?=$row->getElementsByTagName("Cell")->item(0)->nodeValue?></td>
            <input type="hidden" value="<?=$row->getElementsByTagName("Cell")->item(0)->nodeValue?>" name="data[<?=$count?>][product_name]" />
            <td><?=$row->getElementsByTagName("Cell")->item(1)->nodeValue?></td>
            <input type="hidden" value="<?=$row->getElementsByTagName("Cell")->item(1)->nodeValue?>" name="data[<?=$count?>][product_categories]" />
            <td><?=$row->getElementsByTagName("Cell")->item(2)->nodeValue?></td>
            <input type="hidden" value="<?=$row->getElementsByTagName("Cell")->item(2)->nodeValue?>" name="data[<?=$count?>][product_des]" />
            <td><?=$row->getElementsByTagName("Cell")->item(3)->nodeValue?></td>
            <input type="hidden" value="<?=$row->getElementsByTagName("Cell")->item(3)->nodeValue?>" name="data[<?=$count?>][product_thumb]" />
            <td><?=$row->getElementsByTagName("Cell")->item(4)->nodeValue?></td>
            <input type="hidden" value="<?=$row->getElementsByTagName("Cell")->item(4)->nodeValue?>" name="data[<?=$count?>][product_price]" />
            <td><?=$row->getElementsByTagName("Cell")->item(5)->nodeValue?></td>
            <input type="hidden" value="<?=$row->getElementsByTagName("Cell")->item(5)->nodeValue?>" name="data[<?=$count?>][product_title]" />
            <td><?=$row->getElementsByTagName("Cell")->item(6)->nodeValue?></td>
            <input type="hidden" value="<?=$row->getElementsByTagName("Cell")->item(6)->nodeValue?>" name="data[<?=$count?>][product_quantity]" />
        </tr>
    <?php endif;?>
    <?php $count ++;?>
<?php endforeach;?>
</table>
<input type="hidden" name="count" value="<?=$count?>"/>
<input type="hidden" name="csvgo" value="1"/>
<input type="submit" class="sub" value="Import" name="sub"/>
<a href='<?=base_url()?>backend/product' class='bnt'>Quay lại</a>
</form>